<?php
namespace app\web\controller;

use app\model\Theme; 

class Shangjiagroupadd extends Base
{
    public function Shangjiagroupadd()
    {
global $_G, $_P;
//load_func('tpl');
$system = $_G['system'];
$themeid = intval($_P['themeid']);
if($themeid <= 0){
	$themeid = Theme::getDefaultThemenew();
}
$config = 	Theme::getConfig($themeid);
$op = !empty($_P['op']) ? $_P['op'] : 'display';

if ($op == 'delete') {

    db_delete (t_shangjiagroup, array('id'=>$_P['id']));

	return_tips ( '删除成功！', referer (), 'success' );
}

		$do = 'shangjiagroupadd';
		$shangjiaid = intval ( $_P['shangjiaid'] );
		if ($shangjiaid) {	
			//更新加密串
			// db_update ( t_shangjiagroup, array('jiami'=>time()), array ('id' => $shangjiaid) );

			$shangjia = db_find ( "SELECT y.* FROM " . tablename ( t_shangjiagroup ) . " as y
			 	WHERE y.id= " . $shangjiaid );
			// $quanxian=unserialize($shangjia['quanxian']);
		}
		if (checksubmit ()) {
			$data = array (
					'displayorder' => intval($_P['displayorder']),
					'name' => $_P['name'],
					'img' => $_P['img'],
			);
			if (! empty ( $shangjiaid )) {
				db_update ( t_shangjiagroup, $data, array (
						'id' => $shangjiaid
				) );
				message ( '更新成功！', referer (), 'success' );
			} else {
				$data ['uniacid'] = $_G['mpid'];
				$data ['themeid'] = $themeid;
				db_insert ( t_shangjiagroup, $data );
				$shangjiaid = $insertid;
				message ( '添加成功！', referer (), 'success' );
			}
		}
		$return_clicent = get_defined_vars();
return view('/shangjiagroupadd', $return_clicent);	
}
}